package com.bianguo.android.functiondemo.view.activity;

import android.support.annotation.Nullable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.adapter.BaseRecyclerAdapter;
import com.bianguo.android.functiondemo.adapter.MainAdapter;
import com.bianguo.android.functiondemo.view.widget.SlideRecyclerView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

public class SlideActivity extends BaseActivity implements BaseRecyclerAdapter.OnClickItemListener {

    @BindView(R.id.slide_recycler)
    SlideRecyclerView slideRecycler;

    private LinearLayoutManager layoutManager;
    private ArrayList<String> list;
    private MainAdapter adapter;

    @Override
    public int layoutId() {
        return R.layout.activity_slide;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        layoutManager = new LinearLayoutManager(mContext);
        slideRecycler.setLayoutManager(layoutManager);
        list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            list.add("slide ---> " + i);
        }
        adapter = new MainAdapter(mContext, list);
        adapter.setOnClickItemListener(this);
        slideRecycler.setAdapter(adapter);
    }

    @OnClick({R.id.slide_draw_view})
    public void onClickBk(View view) {
        switch (view.getId()) {
            case R.id.slide_draw_view:
                showToast("click draw view");
                break;
        }
    }

    @Override
    public void onClickItemListener(BaseRecyclerAdapter adapter, View view, int position) {
        switch (view.getId()) {
            case R.id.item_main_delete:
                list.remove(position);
                adapter.notifyItemRemoved(position);
                break;
        }
    }
}
